//获取应用实例
const app = getApp();
const towxImg = require('../../../utils/towxImg');
// pages/ajaxc/ajaxc.js
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  funget: function () {
    //ajax
    app.ajaxGet({
      url: app.config.xxx,
      data: {},
      success: function (res) {
        console.log(res, 678)
        if (res.status == 200) {

        }
      },
      fail: function (res) {

      },
      complete: function (res) {

      }
    });
  },
  funpost: function () {

  },
  funupload: function () {
    //res.tempFilePath //微信保存的文件地址
    // 上传
    app.fileUpload({
      url: app.config.xxx,
      filePath: res.tempFilePath,
      name: 'xxx',
      formData: {},
      success: function (response) {
        console.log(response)

      },
      fail: function (response) {
        console.log(response)
      },
      complete: function (response) {

      }
    });

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let code = '```\n// app.js\najaxGet: function (objs) {//get ajax\nvar dataType = objs.dataType ? objs.dataType : "json";\ntry {\n  var storage_SESSION = wx.getStorageSync("storage_SESSION") != "" ? "JSESSIONID=" + wx.getStorageSync("storage_SESSION") : "";\n  // Do something with return value\n  wx.request({\n    url: objs.url,\n    method: "GET",\n    data: objs.data,\n    header: {\n      "content-type": "application/json",\n      "cookie": storage_SESSION\n    },\n    dataType: dataType,\n    success: function (res) {\n      objs.success(res.data, res.statusCode, res.header)\n    },\n    fail: function (res) {\n      objs.fail(res.data, res.statusCode, res.header)\n    },\n    complete: function (res) {\n      objs.complete(res.data, res.statusCode, res.header)\n    }\n  });\n} catch (e) {\n  // Do something when catch error\n};\n\n// ajaxc.js\nfunget: function() {\n  //ajax\n  app.ajaxGet({\n    url: app.config.xxx,\n    data: {},\n    success: function (res) {\n      console.log(res, 678)\n      if (res.status == 200) { }\n    },\n    fail: function (err) { },\n    complete: function (res) { }\n  });\n}\n```\n\n';

    let article = towxImg.dealWithRichText(code);
    this.setData({ article });
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})